package dragon.tagext.sys.dic;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import dragon.core.util.StringUtils;
import dragon.modules.system.dic.dao.DicDaoImpl;

@SuppressWarnings("serial")
public class DicList extends BodyTagSupport {

	private String pid;// 字典根节点ID

	private boolean includeStopData;

	private String var = "dicList";// 封装结果的变量名称

	private DicDaoImpl dd = new DicDaoImpl();

	@Override
	public int doStartTag() throws JspException {

		if (StringUtils.isEmpty(var)) {
			var = "dicList";
		}
		try {
			if (!StringUtils.isEmpty(pid)) {
				pageContext.setAttribute(var, dd.getDics(Integer.parseInt(pid), includeStopData));
			}
		} catch (Exception e) {
			throw new JspException(e);
		}
		return EVAL_BODY_INCLUDE;
	}

	public void setIncludeStopData(boolean includeStopData) {
		this.includeStopData = includeStopData;
	}

	public void setVar(String var) {
		this.var = var;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

}
